<?php

/*

  Action - Reaction	  $2

  +2 Cards
  When another player plays an Attack card, you may reveal this from your hand. If you do, you are unaffected by that Attack.

 */

class Moat extends Card implements iAction, iKingdom, iReaction, iBasic, iReactingCard {

    public function __construct() {
        parent::__construct("Moat", 2);
        $this->undoPlay = false;
        $this->undoBuy = true;

        $this->reactConditions = new ReactionConditions();
        $this->reactConditions->action = array(Attack);
        $this->reactConditions->actor = array(SomeoneElse);
        $this->reactConditions->cardLocation = array(PlayHand);
        $this->reactConditions->limit = OncePerReaction;
        $this->reactConditions->isMandatory = false;
    }

    public function getDescription() {
        return array(
            "+2 Cards",
            "When another player plays an Attack card, you may reveal this from your hand. If you do, you are unaffected by that Attack.");
    }
    
     public function getConditions() {
        return $this->reactConditions;
    }

    public function play(Game $game, $isRealCard) {
        $drawed_cards = $game->drawCards(2);
        ScreenDisplay::addScreenMessage($game, true, "draw " . nicePrint($drawed_cards), "draws " . sizeof($drawed_cards) . " cards");
        $game->cardActionFinished();
        return true;
    }

    public function isReactRelevant(Game $game, $card, $name) {
        return true;
    }

    public function react(Game $game, $card, $name) {
        ScreenDisplay::addScreenMessage($game, true, "reveal ".  nicePrint($this), "reveals ".  nicePrint($this), $name);
        $game->protectFromAttack($name);
        return true;
    }

}

?>